package cn.org.donald.controller;


import cn.org.donald.annotation.PermissionPassRole;
import cn.org.donald.base.BaseController;
import cn.org.donald.base.HttpResult;
import cn.org.donald.service.PermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Donald
 * @since 2021-03-17
 */
@RestController
@RequestMapping("/permission")
@Api(value = "权限控制器")
@PermissionPassRole("admin") // 指定哪个角色不用认证权限
public class PermissionController extends BaseController {

    @Resource
    private PermissionService permissionService;

    @GetMapping("/sync")
    @ApiOperation(value = "同步权限接口信息到数据库")
    public HttpResult sync() {
        boolean flat = permissionService.sync();
        return flat? toSuccess("同步成功!"):toFail("同步失败!");
    }
}

